#pragma once

#include "RasterizerState.hpp"
#include "D3D11Declarations.hpp"
#include "D3D11DeviceContext.hpp"




namespace Engine
{
	namespace Video
	{
		class D3D11RasterizerState
			: public RasterizerState
		{
		public:

			SHARED(D3D11RasterizerState);
			typedef boost::function<void (weak_ptr)>   notify;

		protected:

			D3D11RasterizerState(const notify& destroyedFn);
			void post_create(ptr _this);

		public:

			MAKE_SHARED1(D3D11RasterizerState,notify);
			virtual ~D3D11RasterizerState();



			void setFillmode(Fillmode::Type mode);
			void setCullmode(Cullmode::Type mode);
			void setDepthclipping(bool enabled);



			const ID3D11RasterizerStatePtr& apply(const ID3D11DevicePtr& device, D3D11DeviceContext& context);

		private:

			void update(const ID3D11DevicePtr& device, D3D11DeviceContext& context);

			static D3D11_FILL_MODE fillMode(Fillmode::Type type);
			static D3D11_CULL_MODE cullMode(Cullmode::Type type);

		private:

			weak_ptr                   m_this;
			bool                       m_changed;
			notify                     m_destroyed;

			Fillmode::Type             m_fillmode;
			Cullmode::Type             m_cullmode;
			bool                       m_frontCounterClockwise;
			int32                      m_depthBias;
			float                      m_depthBiasClamp;
			float                      m_slopeScaledDepthBias;
			bool                       m_depthClipping;
			bool                       m_scissorClipping;

			ID3D11RasterizerStatePtr   m_rasterizerState;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
